package avicit.bdp.dcs.utils.api.request;

import avicit.bdp.dcs.utils.api.enums.Method;
import avicit.platform6.core.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RequestAdapterUtil {

    private static final Logger LOG = LoggerFactory.getLogger(RequestAdapterUtil.class);

    public static RequestAdapter getRequestAdapter(String methodType) {
        Method method = Method.getMethod(methodType);
        switch (method) {
            case GET:
                return GetRequestAdapter.instance();
            case POST:
                return PostRequestAdapter.instance();
            default:
                String msg = String.format("不支持的请求类型%s", methodType);
                LOG.error(msg);
                throw new BusinessException(msg);
        }
    }

}
